package com.netspider.entity;

import java.sql.Timestamp;
import java.util.Random;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;



@Data
@AllArgsConstructor
public class QuestionDO {
 
	private String question;
	private String answerA;
	private String answerB;
	private String answerC;
	private String answerD;
	private int correctAnswer;
	private String imageUrl;
	private String bestAnswer;
	private int type;
	private Timestamp createTime;
	private Timestamp updateTime;
 
	public QuestionDO(QuestionVO questionVO) {
		this.setQuestion(questionVO.getQuestion());
		this.setAnswerA(questionVO.getAnswerA());
		this.setAnswerB(questionVO.getAnswerB());
		this.setAnswerC(questionVO.getAnswerC());
		this.setAnswerD(questionVO.getAnswerD());
		this.setCorrectAnswer(questionVO.getCorrectAnswer());
		if (!"".equals(questionVO.getSinaImg())) {
			String imageUrl = "http://ww" + (new Random().nextInt(4) + 1) + ".sinaimg.cn/mw600/" + questionVO.getSinaImg();
			this.setImageUrl(imageUrl);
		} else {
			this.setImageUrl(questionVO.getImageUrl());
		}
		this.setBestAnswer(questionVO.getBestAnswer());
		this.setType(questionVO.getType());
		this.setCreateTime(new Timestamp(System.currentTimeMillis()));
		this.setUpdateTime(new Timestamp(System.currentTimeMillis()));
	}
}